/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.crm.store;

import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.jdbc.OracleTypes;
import queenb.net.datacontrol.DataStatement;
import queenb.net.datacontrol.Param;
import queenb.net.entitybean.N850;
import queenb.web.crm.inteface.N850Inf;
import queenb.web.util.PackageContants;

/**
 *
 * @author Nguyen Hung
 */
public class N850Store extends N850 implements N850Inf{

    @Override
    public List<N850> findAllN850ForCombo(int pnFH000, int pnFH200,int pnFN450, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.LIST_COMBTABN850, OracleTypes.CURSOR, new Param[]{
                       new Param(OracleTypes.INTEGER, pnFH000),
                       new Param(OracleTypes.INTEGER, pnFH200),
                       new Param(OracleTypes.INTEGER, pnFN450),
                       new Param(OracleTypes.CHAR, pvLOGIN)
                   });
           return super.find(dataStatement, N850.class);
        } catch (SQLException ex) {
            Logger.getLogger(N850Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(N850Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(N850Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    @Override
    public int updateN850(int pnPN850, int pnFH000, int pnFH200,
            String pvNV851, String pvNV852, String pvNV853, String pvNV854,
            String pvNV855,String pvLOGIN) {
        try {
            DataStatement dateStatement = new DataStatement(PackageContants.UPDATE_N850, OracleTypes.INTEGER, new Param[]{
                        new Param(OracleTypes.INTEGER, pnPN850),
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.CHAR, pvNV851),
                        new Param(OracleTypes.CHAR, pvNV852),
                        new Param(OracleTypes.CHAR, pvNV853),
                        new Param(OracleTypes.CHAR, pvNV854),
                        new Param(OracleTypes.CHAR, pvNV855),
                        new Param(OracleTypes.CHAR, pvLOGIN)});
            Param[] p = dateStatement.getMapParam();
            return super.update(dateStatement, N850.class);
        } catch (SQLException ex) {
            return 0;
        }
    }

    @Override
    public int deleteN850(int pnPN850, String pvLOGIN) {
         DataStatement dataStatement = new DataStatement(PackageContants.DELETE_N850, OracleTypes.INTEGER, new Param[]{
                    new Param(OracleTypes.INTEGER, pnPN850),
                    new Param(OracleTypes.CHAR, pvLOGIN)});
        try {
            return super.update(dataStatement, N850.class);
        } catch (SQLException ex) {
            Logger.getLogger(N850Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }

    }

    @Override
    public List<N850> findAllN850(String pvLOGIN, int pnFH000, int pnFH200) {
        int t = 0;
        DataStatement dataStatement = new DataStatement(PackageContants.LIST_N850, OracleTypes.CURSOR, new Param[]{
                    new Param(OracleTypes.CHAR, pvLOGIN),
                    new Param(OracleTypes.INTEGER, pnFH000),
                    new Param(OracleTypes.INTEGER, pnFH200)
                });
        try {
            return super.find(dataStatement, N850.class);
        } catch (SQLException ex) {
            Logger.getLogger(N850Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(N850Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(N850Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
    
}
